﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using AppSocketModel; 
using BCGPSCommon;
using BCGPSRESTful.WebApiConfig;
using AppSocketService.Relay;

namespace BCGPSRESTful.Controllers.Page.Relay
{
    /// <summary>
    /// GPS数据转发
    /// </summary>
    [ApiExplorerSettings(GroupName = "CompanyPage")]
    [Route("api/[controller]")]
    [ApiController]
    public class RelayController : PageBaseController
    {
        private IRelayService relayService;

        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary> 

        public RelayController(IRelayService relayService)
        {
            this.relayService = relayService;
        }
        #endregion


        #region 添加
        /// <summary>
        /// 添加新的转发规则
        /// </summary>
        /// <param name="relay_request_dto">数据转发模型</param>
        /// <returns></returns>
        [HttpPost("[action]")]
        [ProducesResponseType(typeof(RelayDto), 200)]
        public ActionResult<RelayDto> Add(RelayRequestDto relay_request_dto)
        {
            return relayService.Add(relay_request_dto);
        }
        #endregion

        #region 修改
        /// <summary>
        /// 修改转发规则
        /// </summary>
        /// <param name="relay_dto">数据转发模型</param>
        /// <returns></returns>
        [HttpPut("[action]")]
        [ProducesResponseType(typeof(RelayDto), 200)]
        public ActionResult<RelayDto> Update(RelayDto relay_dto)
        {
            return relayService.Update(relay_dto);
        }
        #endregion


        #region 删除
        /// <summary>
        /// 删除转发规则
        /// </summary>
        /// <returns></returns>
        [HttpDelete("[action]")]
        [ProducesResponseType(typeof(bool), 200)]
        public ActionResult<bool> Delete()
        {
            return relayService.Delete();
        }
        #endregion


        #region 获取
        /// <summary>
        /// 获取当前账户数据转发规则
        /// </summary>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(RelayDto), 200)]
        public ActionResult<RelayDto> Get()
        {
            return relayService.Get();
        }
        #endregion

        #region 发送转发服务控制命令
        /// <summary>
        /// 发送转发服务控制命令
        /// </summary>
        /// <param name="relay_server_run_state">转发服务运行状态</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(bool), 200)]
        public ActionResult<bool> SendControlCmd(RelayServerRunState relay_server_run_state )
        {
            return relayService.SendControlCmd(relay_server_run_state);
        }
        #endregion
    }
}